<?php

namespace App\Http\Controllers\Api;

use App\Services\WeChatOfficialAccountService;

class WeChatOfficialAccountController
{
    public function serve(WeChatOfficialAccountService $weChatOfficialAccountService)
    {
        return $weChatOfficialAccountService->serve();
    }

    public function network(WeChatOfficialAccountService $weChatOfficialAccountService)
    {
        $api = $weChatOfficialAccountService->getClient();
        $response = $api->postJson('/cgi-bin/callback/check',[
            'action' => 'all',
            'check_operator' => 'DEFAULT',
        ]);
        dd($response->getContent());
    }

    public function token(WeChatOfficialAccountService $weChatOfficialAccountService)
    {
        $accessToken = $weChatOfficialAccountService->getAccessToken();
        $accessToken->getToken(); // string
        dd( $accessToken->getToken());
    }

    public function ip(WeChatOfficialAccountService $weChatOfficialAccountService)
    {
        $api = $weChatOfficialAccountService->getClient();
        $response = $api->get('/cgi-bin/get_api_domain_ip');
        dd($response->getContent());
    }
}
